﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EPlanet.Web.UI.WebControls;
using Web.Views.Public;

namespace Web.Views.Public
{
    public partial class SearchList :PageBase
    {
        protected void Page_Load(object sender, System.EventArgs e)
        {
              try
                {
		
            SetPageProperty();
            // 在此处放置用户代码以初始化页面
            if (!IsPostBack)
            {
                ShowList();
            }
            CreateToolMenu(Toolbar1, ToolMenuType.TYPE_MainList);
            base.CheckListAuthorities(Toolbar1, ucList_SearchList);
                }
              catch (Exception ex)
              {
                  WriteErrorLog(ex.Message);
                  ExceptionMsg();
              }
        }

        #region PageLoad函数

        #region SetMenuValue
        /// <summary>
        /// 设置页面的菜单属性
        /// </summary>
        private void SetPageProperty()
        {
            base.MenuID = this.Request.QueryString.Get("MenuID");
        }
        #endregion

        #region show voucher edit
        private void ShowList()
        {
            ucList_SearchList.VoucherID = this.Request.QueryString.Get("VoucherID");
            ucList_SearchList.ShowViewCommand = false;
            ucList_SearchList.ShowDeleteCommand = false;
            ucList_SearchList.ShowEditCommand = false;
            ucList_SearchList.ShowListCheck = false;
        }
        #endregion

        #endregion

        #region ToolBar Event
        private void Toolbar1_MenuItemClick(object sender, MenuItemClickEventArgs e)
        {
            try
            {
            switch (e.EventItem.ID.ToString().ToLower())
            {
                case "tbexport":
                    this.ExportListToExcel(ucList_SearchList.GetExportData(), this);
                    break;
                case "tbhelp":
                    break;
            }
              }
            catch (Exception ex)
            {
                WriteErrorLog(ex.Message);
                ExceptionMsg();
            }
        }
        #endregion
        /// <summary>
        /// 设置按钮可用性
        /// </summary>
        private void SetToolBarVisible()
        {
            ToolBarHelper.SetToolBarVisible(Toolbar1, ToolBarID.Export, false);
        }

        #region Web 窗体设计器生成的代码
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.Toolbar1.MenuItemClick += new MenuItemClickedEventHandler(this.Toolbar1_MenuItemClick);
        }
        #endregion

        protected override void OnPreRender(EventArgs e)
        {
            SetTooBarButton();
            base.OnPreRender(e);
        }

        private void SetTooBarButton()
        {
            ToolBarHelper.SetToolBarVisible(Toolbar1, ToolBarID.Add, false);
            ToolBarHelper.SetToolBarVisible(Toolbar1,ToolBarID.Delete, false);
        }
    }
}
